<?php

f()->import('form');

class _F_EXTENSION_GRID_ extends _F_EXTENSION_ {
	
//	public $widgets = array();
	
	public function __construct() {
		f()->template_path_list[] = dirname(__FILE__).'/templates';
		f()->form()->register_widget('grid',array($this,'grid'));
	}
	
	public function grid($id,$label,$columns,$data,$params = array()) {
		f()->style('/extensions/grid/styles/grid.less');
		f()->import('jquery');
		f()->jquery();
		f()->script('/extensions/grid/scripts/grid.js');
		$parent = $this->_f_this_;
		$form = $parent->form;
		$parent->elements[$id] = array_merge($form->default_properties,array(
			'template' => 'grid.table',
			'select' => false,
			'multiselect' => false,
			'table' => true,
		),$params,array('id' => $id, 'widget' => 'grid',
			'label' => $label, 'columns' => $columns, 
			'data' => $data));
		return $parent;
	}
	
}

new _F_EXTENSION_GRID_;
